home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
asmutil
/
asm_n_z.zip
/
STROBE.ASM
< prev
next >
Wrap
Assembly Source File
|
1989-01-13
|
21KB
|
532 lines
page ,132 ; print in condensed mode
title STROBE - Monitor a memory field for changes - P. Quale 3/87
cseg segment para
assume cs:cseg,ds:cseg,es:nothing,ss:nothing
org 2ch
env_seg dw ? ;pointer to our copy of environment
org 80h ;parm list starts here...
parm_len db ? ;its length
parm_char db 127 dup(?) ;the parms
org 100h
strobe proc near
begin:
jmp init ;go to once-only code
prog_id:db 'STROBE 1.02 '
db 'IBM Internal Use Only '
db 'P. Quale 03/87'
id_end equ $
;history:
; 1.01, 05/26/87: revised to incorporate changes suggested by Kevin McCarthy.
; The addresses being monitored can now be patched on the fly by patching
; new values into the fields intvect and intvect2, which have been
; changed from EQU values to doubleword pointers.
; 1.02, 01/13/89: STROBE now releases its memory when 'R'emoved. Also
; removed a potential BRS bug if a derivative program were to have an
; ASSUME DS:CSEG directive in the timer interrupt routine, by changing
; the exit statement from 'JMP OLDVECT' to 'JMP CS:OLDVECT'.
;-------macro to simplify window repositioning
posw macro name,row,column ;convert row/column location
name equ ((row-1)*160)+((column-1)*2) ;to position in video buffer
endm
;-------macro to define field positions within the window
posf macro name,row,column ;convert line/column location
name equ corner1+((row-1)*160)+((column-1)*2) ;to pos in video buffer
endm
db 0 ;waste a byte to align patch area nicely
old_vect label dword ;original timer vector saved here
old_ofs dw 0 ;offset
old_seg dw 0 ;segment
; keep old_vect as close to front of program as possible
page
;-------entries on this page are grouped together to facilitate
;-------changes in window location or storage area(s) being tracked
;-------next entries define the control block to be "watched"
;-------in this case, we watch to see when int 21 gets hooked
intnum equ 021h ;interrupt number we care about
intvect dw intnum*4,0 ;offset, segment (patchable)
prev_value dw 2 dup(?) ;its previous (or initial) contents
;-------any other memory fields of interest
intnum2 equ 02fh ;another interrupt number we care about
intvect2 dw intnum2*4,0 ;offset, segment (patchable)
;-------next three entries define the window size and location
posw corner1,1,62 ;upper left corner of window
posw corner2,1,80 ;upper right corner
posw corner4,5,80 ;lower right corner
;-------next entries define location of each field within the window
posf out1,1,1 ;moving blob goes here on line 1 of window
posf out2,2,10 ;entry count here at line 2 col 10 of window
posf out3,3,10 ;contents of major block being tracked
posf out4,4,10 ;yet another block being tracked
posf out5,5,10 ;cs:ip of routine running when timer went off
;-------end of EQUs, etc. peculiar to a specific application of STROBE
page
;-------next two equates are needed by the window-clearing code
windwid equ (corner2-corner1+2)/2 ;width in screen positions
winddep equ (corner4-corner2+160)/160 ;depth in lines
clknum equ 08h ;timer interrupt number
clkvect equ clknum*4 ;its vector address
;-------window attributes/colors used to indicate a value change
table_mono db 20h,70h,28h,29h ;normal, reversed, bright, underlined
table_color db 07h,04fh,2fh,5fh ;white on: black, red, green, magenta
max_change equ 3 ;n'color changes before we recycle (zero-based)
change_index dw (max_change) ;forces a start at first color
flags db 0 ;flag bits...
mono equ 01h
color equ 02h
sync equ 04h
vidseg dw 0 ;video segment address
vidsegm equ 0b000h ;video segment address if mono
vidsegc equ 0b800h ;video segment address if color
attrib db 0 ;screen attribute byte
tick_count dw 0 ;cyclic index into tick-display line
max_tick equ 18 ;limit for tick_count
blob equ 0feh ;timer-tick char. feh=small square, dbh=big one
entry_count dw 0 ;count of timer-tick entries to this program
count_carry db 0 ;how many times entry_count wrapped
ss_save dw 0 ;ss saved here upon entry
sp_save dw 0 ;sp saved here
;-------enter here on timer interrupt
timer_int:
assume cs:cseg,ds:nothing,es:nothing,ss:nothing
pushf ;preserve flags
;-------switch to our own stack
cli ;disable interrupts (and keep them that way)
mov ss_save,ss
mov sp_save,sp
push cs
pop ss
lea sp,stack_end
nop
;-------save the rest of the registers
push ax
push bx
push cx
push dx
push bp
push di
push si
push ds
push es
;-------set ds for our internal variables, es for video buffer
push cs
pop ds
assume ds:cseg
push vidseg ;set video segment address
pop es ;...
;-------make sure our stack size hasn't been exceeded
; (for testing; probably an unnecessary check now)
mov ax,0fefeh ;string that must still be there
cmp ax,stack_bottom ;has anyone overrun our stack?
je check_major ;no
tight_loop: ;yes, so stop right here and now
mov ax,05341h ;but leave tracks
mov es:corner1,ax ;upper left corner of window
jmp short tight_loop
check_major:
;-------check to see if value of memory field we're watching has changed:
push ds ;save ds for a moment
assume ds:nothing
lds bx,dword ptr intvect ;load dword pointer
mov ax,ds:[bx] ;pick up first 2 bytes of field
mov bx,ds:[bx+2] ;next 2 bytes
pop ds
assume ds:cseg
cmp ax,prev_value ;still the same?
jne has_changed ;no
cmp bx,prev_value+2 ;still the same?
je clear_window ;yes
has_changed: ;new value. save new field value and
call save_major ;alert user by changing window background color
clear_window:
;-------clear the screen window and set the background color
mov al,20h ;get a blank
mov ah,byte ptr attrib ;pick up window color byte
mov di,corner1 ;where to start clearing
mov cx,winddep ;n'lines in window
call sync_cga ;avoid flicker during writes if CGA display
clrline:
push cx ;save line count
mov cx,windwid ;width of window
clrbyte:
mov word ptr es:0[di],ax ;clear one screen position
inc di
inc di
loop clrbyte ;loop for all positions this line
add di,160-(windwid*2) ;point to next line of window
pop cx ;all window lines cleared?
loop clrline ;no
;-------move blob from left to right on top line to indicate timer-tick rate